package com.hdd.biz.huodong.controller;


import com.hdd.biz.finance.dto.PaymetListRequest;
import com.hdd.biz.huodong.dto.*;
import com.hdd.biz.huodong.entity.ActivityPrize;
import com.hdd.biz.huodong.service.ActivityPrizeService;
import com.hdd.biz.huodong.service.ActivityService;
import com.hdd.dto.SuperResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-07-29
 */
@RestController
@RequestMapping("/huodong")
@Api(value = "活动模块（后台）",tags = {"活动模块（后台）"})
public class ActivityController {


    @Autowired
    private ActivityService activityService;
    @Autowired
    private ActivityPrizeService prizeService;

    @PostMapping("/list")
    @ApiOperation(value = "活动列表" ,notes = "")
    public SuperResponse list(@Valid @RequestBody ActivityListDto request ){
        return activityService.list(request);
    }


    @PostMapping("/info")
    @ApiOperation(value = "活动详情" ,notes = "")
    public SuperResponse info(@Valid @RequestBody ActivityDto request ){
        return activityService.info(request);
    }

    @PostMapping("/add")
    @ApiOperation(value = "活动添加" ,notes = "")
    public SuperResponse record(@Valid @RequestBody ActivityInfoDto request ){
        return activityService.add(request);
    }


    @PostMapping("/update")
    @ApiOperation(value = "活动修改" ,notes = "")
    public SuperResponse update(@Valid @RequestBody ActivityInfoDto request ){
        return activityService.update(request);
    }

    @PostMapping("/stop")
    @ApiOperation(value = "活动开启/停止" ,notes = "")
    public SuperResponse stop(@Valid @RequestBody ActivityDto request ){
        return activityService.stop(request);
    }

    @PostMapping("/prize")
    @ApiOperation(value = "活动奖品列表" ,notes = "")
    public SuperResponse prize(@Valid @RequestBody ActivityDto request ){
        SuperResponse response = new SuperResponse();
        response.setItems(prizeService.prize(request.getId()));
        return response;
    }


    @PostMapping("/prizeAdd")
    @ApiOperation(value = "活动奖品添加" ,notes = "")
    public SuperResponse prizeAdd(@Valid @RequestBody PrizeAddDto request ){
        SuperResponse response = new SuperResponse();
        ActivityPrize activityPrize = new ActivityPrize();
        BeanUtils.copyProperties(request,activityPrize);
        prizeService.add(activityPrize);
        return response;
    }

    @PostMapping("/prizeDel")
    @ApiOperation(value = "活动奖品删除" ,notes = "")
    public SuperResponse prizeDel(@Valid @RequestBody PrizeDelDto request ){
        SuperResponse response = new SuperResponse();
        prizeService.del(request.getId(),request.getActivityId());
        return response;
    }
}

